/*
 * Copyright (c) 2013 by Chances.
 * $CVSHeader$
 * $Author$
 * $Date$
 * $Revision$
 */
package chances.epg.search.analyzer;

import java.io.Reader;

import org.apache.lucene.analysis.util.CharArraySet;
import org.apache.lucene.analysis.util.CharTokenizer;
import org.apache.lucene.util.Version;

/**
 * Class comments.
 *
 * @author <a href="mailto:libf@chances.com.cn">libf</a>
 */
public class SplitTokenizer extends CharTokenizer {
    private CharArraySet stopWords;
    
    /**
     * @param matchVersion
     * @param input
     */
    public SplitTokenizer(Version matchVersion, Reader input,CharArraySet stopWords) {
        super(matchVersion, input);
        this.stopWords = stopWords;
    }

    /* (non-Javadoc)
     * @see org.apache.lucene.analysis.util.CharTokenizer#isTokenChar(int)
     */
    @Override
    protected boolean isTokenChar(int c) {
        char[] temp = Character.toChars(c);
        return !stopWords.contains(temp, 0, temp.length);
    }
}
